﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Script including demo</title>
    <!--script type="text/javascript" src="../DHTiny.js"></script>
    <script type="text/javascript" src="../dom.js"></script-->
</head>
<body>
<div id="xem">
<script type="text/javascript" src="http://video.google.com/videosearch?q=go&num=10&output=rss"></script>
</div>

<script type="text/javascript">
function jsonFlickrFeed(feed){
    z='';  
    for (x=0; x<feed.items.length; x++) { 
        tmp=feed.items[x].media.m;
        tmp=tmp.replace(/_m\.jpg/g,'_s.jpg');
        z+='<img src="'+tmp+'" alt="some img" width="75px" height="75px" style="margin: 2px;">';
    }  
    document.getElementById('pics').style.display='block';
    document.getElementById('pics').innerHTML=z;
}


function makeLink(keyWord) {
    keyWord = escape(keyWord);
    //return 'http://flickr.com/services/feeds/photos_public.gne?tags=' + keyWord + '&format=json';    
    //alert('http://vdict.com/showlist_similarword.php?limit=20&input=chi&dict=1&word='+ keyWord);
    //return 'http://vdict.com/showlist_similarword.php?limit=20&input='+keyWord+'&dict=1&word='+ keyWord;
    return "http://video.google.com/videosearch?q="+keyWord+"&num=10&output=rss";

}

bsn = {};
_b = bsn;

bsn.Autosuggest = {};
bsn.AutoSuggest.prototype.setSuggestions = function(req, input) {
    alert("Tu nhien thay suong")
}

_b.AutoSuggest.prototype.createList=function(arr) {
    alert("Chim ");
}

function searchFlickr() {
    var headID = document.getElementsByTagName("head")[0];
    var newScript = document.createElement('script');
    keyWord = document.getElementById('tags').value;
    
    document.getElementById('tags').value='';
    newScript.type = 'text/javascript';
    newScript.src = makeLink(keyWord);
    newScript.id = "scr";
        
    var pics = document.getElementById('pics');
    pics.style.display='block';
    pics.innerHTML="Loading...";
    
    headID.appendChild(newScript);
    
    /*window.onerror = function() {
         var script = document.getElementById("scr");
         alert(script + " 1" + script.innerHTML + " 2" + script.text+ " 3" + script.textContent);
         document.getElementsByTagName("head")[0].removeChild(script);
    }*/
    
    return false;
}

</script>

<form action = "#" onsubmit="return searchFlickr();">
<input type='text' size='40' id='tags'>&nbsp;&nbsp;&nbsp;
<input type='submit'>
</form>

<div style='border: 1px solid black; width: 100%; display: none;' id='pics'></div>
</body>
</html>
